package com.harlan.viewbindingstudy;

import android.content.Intent;
import android.os.Bundle;


import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.harlan.viewbindingstudy.databinding.FragmentBlankBinding;
import com.harlan.viewbindingstudy.kotlin.KotlinActivity;
import com.harlan.viewbindingstudy.mvp.MVPActivity;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;


public class BlankFragment extends Fragment {
    FragmentBlankBinding blankBinding;


    public BlankFragment() {
        // Required empty public constructor
    }


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        blankBinding = null;
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        blankBinding = FragmentBlankBinding.inflate(inflater, container, false);

        return blankBinding.getRoot();
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        blankBinding.fragmentUse.setText("在fragment使用ViewBing");
        blankBinding.dialog.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                MyDialog myDialog = new MyDialog(getActivity());
                myDialog.show();
            }
        });
        blankBinding.pop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ActivationPopWindow popWindow = new ActivationPopWindow(getActivity());
                popWindow.show();
            }
        });
        blankBinding.includeUse.includeId.setText("这个是使用include里的");
        blankBinding.kotlinUse.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(), KotlinActivity.class);
                startActivity(intent);
            }
        });
        blankBinding.baseUseViewbing.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(), MVPActivity.class);
                startActivity(intent);
            }
        });
    }
}